<?php
namespace Admin\Controller;
class LogoController extends CommonController {
    public function _initialize() {
        parent::_initialize();
    }

    public function index() {
        $where = array('name'=>'logo');
        $list = M('setting')->where($where)->find();
        $this->info = json_decode($list['data'],true);
        $this->display();
    }

    public function edit() {
        if(IS_POST){
            $config = M('setting');
            $info = $_POST['info'];
            $name = array_keys($info);
            $values = array_values($info);
            $name = $name[0];
            $value = json_encode($values[0]);
            $where = array('name'=>$name);
            if($config->where($where)->find()){
                if($config->where($where)->setField('data', $value)){
                    $this->success('保存成功！');
                }else{
                    $this->error('保存失败！');
                }
            }else{
               if($config->add(array('name'=>$name,'data'=>$value))){
                   $this->success('保存成功！');
               }else{
                   $this->error('保存失败！');
               }
            }
        }
    }

}